<template>
    <view class="cu-form-group pos-r" @click="showSelect">
    	<view class="title">{{label}}</view>
		<view class="flex1 tar padr2 flex-r flex-end">
			<view><user-selector :show="showStatus" v-model="valueInside" :placeholder="placeholder"></user-selector></view>
			<view v-show="!$com.isbool(valueInside)">{{placeholder}}</view>
		</view>
		<view class="fa fa-angle-right"></view>
		<ripple></ripple>
    </view>
</template>

<script>
	import userSelector from '../../app/machine/user_selector.vue'
    export default {
        name: "suser",
		components:{userSelector},
        props: {
            value: {
				type:String,
				default:""
			},
			model: "",
			label: {
				type:String,
				default:"未设置"
			},
			placeholder: {
				type:String,
				default:"请输入"
			}
        },
        data() {
            return {
                valueInside:'',
                showText:'',
                showStatus:false
            }
        },
        methods: {
           showSelect(){
			   this.showStatus = Math.random()
		   }
        },
        mounted() {
				this.log(this.value)
			if(this.$com.isbool(this.value)){
				this.valueInside = this.value
			}
            // this.valueInside = this.val
        },
		watch:{
			value(curVal,oldVal){
				this.log(curVal)
				this.log(oldVal)
				this.valueInside = curVal
				// if(this.$com.isbool(curVal)){
				// 	this.$api.res('api_/machine_users',this.$com.iriId(curVal),res=>{
				// 		this.showText = res.name
				// 	})
				// }
			},
			valueInside(curVal,oldVal){
				this.$emit('input',curVal)
			}
		}
    }
</script>

<style>
    .cu-form-group .title {
    	min-width: calc(4em + 15px);
    }
</style>
